/**
 * @Author: easten
 * @Created: 2024-08-09 00:54:32
 * @Description: 权限维护接口
 *
 */
import { SysPermission } from "_common/entity";
import { createRequest, RequestMethod } from "_common/request";
import { AxiosInstance } from "axios";
export class ApiPermission {
  /**
   * @description 请求实例
   * @type {RequestMethod}
   * @memberof ApiDevice
   * */
  request: RequestMethod;
  url: string = "api/sys/permission";

  /**
   * @description 构造函数
   * @param config axios 配置
   */
  public constructor(instance: AxiosInstance) {
    // axios 实例化
    this.request = createRequest(instance);
  }

  /** 创建权限 */
  create(data: SysPermission) {
    return this.request.post<boolean>(this.url + "/create", data);
  }

  /** 更新权限 */
  update(data: SysPermission) {
    return this.request.put<boolean>(this.url + "/update", data);
  }

  /** 删除权限 */
  delete(id: number) {
    return this.request.delete<boolean>(this.url + "/delete/" + id);
  }

  /** 获取权限列表 */
  getList() {
    return this.request.get<SysPermission[]>(this.url + "/get-list", {});
  }
}
